<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<c:choose>
	<c:when test="${empty stu }">
	您的操作有误
	</c:when>
	<c:otherwise>
	
<form action="${pageContext.request.contextPath}/stu" onsubmit="return beforeSub()">
	<input type="hidden" name="flag" value="doEdit">
	<input type="hidden" name="id" value="${stu.id }">
	<table  class="table table-bordered">
		<tr>
			<th colspan="2">学生信息修改</th>
		</tr>
		<tr>
			<td width="150px">姓名</td>
			<td><input type="text" value="${stu.userName}"  class="form-control" name="userName" placeholder="请输入您的姓名" ></td>
		</tr>
		
		<tr>
			<td>性别</td>
			<td>
				      <label class="checkbox-inline"><input type="radio" id="male" name="gender" value="0" checked>男</label>
				      &nbsp;&nbsp;&nbsp;
				      <label class="checkbox-inline"><input type="radio" id="female" name="gender" value="1" checked>女</label>
				
			</td>
		</tr>
		<tr>
			<td>出生日期</td>
			<td>
				<input type="date" value="${stu.birthdayYMDStr}" name="birthday" class="form-control mt-3">
			</td>
		</tr>
		<tr>
			<td>爱好</td>
			<td>
				<label class="checkbox-inline"><input type="checkbox" id="hobby0" name="hobby" value="0">爬山</label>&nbsp;
				<label class="checkbox-inline"><input type="checkbox" id="hobby1" name="hobby" value="1">打篮球</label>&nbsp;
				<label class="checkbox-inline"><input type="checkbox" id="hobby2" name="hobby" value="2">听音乐</label>&nbsp;
				<label class="checkbox-inline"><input type="checkbox" id="hobby3" name="hobby" value="3">跳舞</label>&nbsp;
				<label class="checkbox-inline"><input type="checkbox" id="hobby4" name="hobby" value="4">玩游戏</label>&nbsp;
				
				
			</td>
		</tr>
		<tr>
			<td>在读院校</td>
			<td>
				<select name="school"  class="form-control">
					<option value="qlnu">齐鲁师范学院</option>
					<option value="sdu">山东大学</option>
					<option value="sdnu">山东师范大学</option>
				</select>
			</td>
		</tr>
		
		<tr>
			<td>其他</td>
			<td>
				<textarea name="temp"  class="form-control">${stu.temp }</textarea>
			</td>
		</tr>
		<tr>
			<td align="center" colspan="2">
				<input type="submit" class="btn btn-secondary" value="点击提交">
				&nbsp;
				<input type="button" class="btn btn-secondary" onclick="javascript:history.go(-1)" value="返回">
			</td>
		</tr>
	</table>
</form>
<c:if test="${not empty stu.hobbies }">
	<c:forEach var="hobby" items="${stu.hobbies }">
		<script type="text/javascript">
			document.getElementById("hobby${hobby}").checked=true;
		</script>
	</c:forEach>
</c:if>
<script type="text/javascript">
	var genderStr = "${stu.gender}";
	if(genderStr == "0"){
		document.getElementById("male").checked=true;
	}else{
		document.getElementById("female").checked=true;
	}
	document.getElementsByName("school")[0].value="${stu.school}";
</script>
</c:otherwise>
</c:choose>
</body>
</html>